% $Id: arrow.ps,v 1.11 2003/08/09 22:37:33 billd Exp $

/tan
  {
  dup
  sin exch cos div
  } bind def

/arrow_dict 12 dict def
arrow_dict /arrow_mtrxstor matrix put

/arrow
  {
  arrow_dict 
    begin

    /alpha exch def
    /y2 exch def
    /x2 exch def
    /y1 exch def
    /x1 exch def
  
    /arrow_oldmtrx arrow_mtrxstor currentmatrix def
  
    /dx x2 x1 sub def
    /dy y2 y1 sub def
  
    /len dx dx mul dy dy mul add sqrt def
    
	 % complicated way to say theta = 90 - alpha?
    /theta 1 alpha tan atan def
	 % complicated way to say rad = len * sin(alpha) / (1 - sin(alpha))?
    /rad len alpha tan mul 
      theta sin alpha tan theta cos -1 add mul add div def
  
    x1 y1 translate
    dy dx atan rotate
  
    len 0 M2
    rad neg 0 rad theta 360 theta sub arcn
    closepath
  
    arrow_oldmtrx setmatrix
    end
  } bind def

